package org.vectrics.recruiter.struts.admin.person;

import javax.servlet.jsp.JspException;

import org.vectrics.cv.University;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.struts.VectricsStrutsAction;

/**
 * @author pgoette
 * 
 * Clase encargada de mostrar los datos de Universidad para editarlo.
 */
public class EditUniversityAction extends VectricsStrutsAction {


	@Override
	protected String doExecute(VectricsActionData actionData)
			throws JspException {

		String forward = "success";
		// Busco el id
		String idUniversity = actionData.getRequest().getParameter("universityId");
		UniversityForm form = (UniversityForm) actionData.getForm();
		
        if ((idUniversity!=null) && (!idUniversity.trim().equals(""))) {
        	// Busco la Universidad segun el id.
        	University university = RecruitServiceLocator.getPersonService().findUniversity(new Long(idUniversity));
        	form.setId(university.getId().toString());
        	form.setName(university.getName());
		}
        
		return forward;
	}

}
